//
//  CZQOderDetailView.m
//  coachmanage
//
//  Created by 众拳科技 on 2018/3/21.
//  Copyright © 2018年 众拳科技. All rights reserved.
//

#import "CZQOderDetailView.h"

@implementation CZQOderDetailView
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        /**
         订单进度
         */
        CommonInputView *nameInputView = [[CommonInputView alloc] init];
        nameInputView.titleLabel.text = @"订单进度";
        nameInputView.titleTF.text = @"游泳";
        nameInputView.titleTF.userInteractionEnabled = NO;
        [self addSubview:nameInputView];
        self.oderProInputView = nameInputView;
        
        /**
         订单已提交等待教练接单
         */
        UILabel *lab = [UILabel new];
        lab.numberOfLines = 0;
        lab.font = MidFont;
        lab.textColor = CSColorFromRGB(0x999999);
        
        NSString *str = @"订单已提交,等待教练接单\n(00:30:00后教练未确认，订单自动取消)";
        
        NSMutableAttributedString *attrStr = [[NSMutableAttributedString alloc]
                                              initWithString:str];
        
        [attrStr addAttribute:NSForegroundColorAttributeName value:
         [UIColor redColor] range:NSMakeRange(14, 8)];
        
        lab.attributedText = attrStr;
        
        [self addSubview:lab];
        self.oderStasuLable = lab;
        
        /**
         立即抢单
         */
        UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
        btn.backgroundColor = [UIColor lightGrayColor];
        btn.contentEdgeInsets = UIEdgeInsetsMake(5, 5, 5, 5);
        [btn setTitleColor:TextColor];
        [btn setTitle:@"立即抢单"];
        [self addSubview:btn];
        self.oderGoBtn = btn;
        
        UIView *sepView = [UIView new];
        sepView.backgroundColor = BackGroundColor;
        [self addSubview:sepView];
        self.sepView = sepView;
        
        /**
         头像
         */
        UIImageView *headImageView = [[UIImageView alloc] init];
        headImageView.image = PlaceHold;
        headImageView.backgroundColor = CSRedColor;
        headImageView.contentMode = UIViewContentModeScaleAspectFill;
        headImageView.layer.masksToBounds = YES;
        headImageView.layer.cornerRadius = 30;
        [self addSubview:headImageView];
        self.headImageView = headImageView;
        
        
        /**
         昵称
         */
        UILabel *nickNameLabel = [[UILabel alloc] init];
        nickNameLabel.font = MidBigFont;
        nickNameLabel.textColor = CSColorFromRGB(0x999999);
        nickNameLabel.text = @"暗暗";
        [self addSubview:nickNameLabel];
        self.nickNameLabel = nickNameLabel;
        
        /**
         性别
         */
        UIImageView *sexImage = [[UIImageView alloc] init];
        sexImage.image = [UIImage imageNamed:@"icon_female"];
        [self addSubview:sexImage];
        self.sexImage = sexImage;
        
        
        
        /**
         电话Label
         */
        UILabel *phoneLabel = [[UILabel alloc] init];
        phoneLabel.text = @"13152741472";
        phoneLabel.font = MidFont;
        phoneLabel.textColor = CSColorFromRGB(0x999999);
        [self addSubview:phoneLabel];
        self.phoneLabel = phoneLabel;
        
        /**
         年龄
         */
        UILabel *ageLabel = [[UILabel alloc] init];
        ageLabel.text = @"年龄：22岁";
        ageLabel.font = MidFont;
        ageLabel.textColor = CSColorFromRGB(0x999999);
        [self addSubview:ageLabel];
        self.ageLabel = ageLabel;
        
        UIView *sepView1 = [UIView new];
        sepView1.backgroundColor = BackGroundColor;
        [self addSubview:sepView1];
        self.lineView = sepView1;
        
        [self setConstraints];
    }
    return self;
}

-(void)setConstraints
{
    
    //订单进度
    [self.oderProInputView mas_remakeConstraints:^(MASConstraintMaker *make) {

        make.top.left.width.mas_equalTo(self);

        make.bottom.mas_equalTo(self.oderStasuLable.mas_top).offset(-10);

    }];
    
    [self.oderStasuLable mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(self.oderProInputView.mas_bottom).offset(10);
        
        make.left.mas_equalTo(self).offset(10);
        
    }];
    
    //立即抢单
    [self.oderGoBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.centerY.mas_equalTo(self.oderStasuLable);
        
        make.right.mas_equalTo(self).offset(-10);
        
    }];
    
    //分割线
    [self.sepView mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(self.oderStasuLable.mas_bottom).offset(10);
        
        make.left.width.mas_equalTo(self);
        make.height.mas_equalTo(10);
        
        
    }];
    
    /**
     头像
     */
    [self.headImageView mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(self.sepView.mas_bottom).offset(15);
        
        make.centerX.mas_equalTo(self);
        
        make.width.height.mas_equalTo(60);
    }];
    
    /**
     昵称
     */
    [self.nickNameLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(self.headImageView.mas_bottom).offset(10);
        
        make.right.mas_equalTo(self.headImageView.mas_centerX).offset(10);
    }];
    
    /**
     性别
     */
    [self.sexImage mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.centerY.mas_equalTo(self.nickNameLabel);
        
        make.left.mas_equalTo(self.nickNameLabel.mas_right).offset(5);
    }];
    
    
    /**
     年龄
     */
    [self.ageLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.centerX.mas_equalTo(self.headImageView);
        
        make.top.mas_equalTo(self.nickNameLabel.mas_bottom).offset(5);
    }];
    
    /**
     电话Label
     */
    [self.phoneLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(self.ageLabel.mas_bottom).offset(5);
        
        make.centerX.mas_equalTo(self.headImageView);
        
        make.bottom.mas_equalTo(self).offset(-10);
        
    }];
    
    /**
     横线
     */
    [self.lineView mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.left.width.mas_equalTo(self);
        
        make.height.mas_equalTo(1);
        
        make.bottom.mas_equalTo(self).offset(-1);
        
    }];
    
    
    
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
